//
//  AutoConectCell.m
//  MOPAI
//
//  Created by he weixian on 13-4-10.
//  Copyright (c) 2013年. All rights reserved.
//

#import "AutoContentCell.h"


@implementation AutoContentCell
@synthesize content;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.content = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        self.content.textColor = [UIColor blackColor];
        self.content.font = [UIFont systemFontOfSize:14.5];
        self.content.backgroundColor = [UIColor clearColor];
        self.content.numberOfLines = 0;
        self.content.lineBreakMode = NSLineBreakByTruncatingTail;
        [self addSubview:self.content];
    }
    return self;
}

- (CGSize)returnRectWithString:(NSString *)string andWidth:(float )width
{
    UIFont *font=[UIFont systemFontOfSize:14.5];
    CGSize size = [string sizeWithFont:font constrainedToSize:CGSizeMake(width, 1000) lineBreakMode:NSLineBreakByTruncatingTail];
    return size;
}

-(void)reLayout:(int )width andContentStr:(NSString *)contentStr;
{
    float w = width - kContentWidthSpace * 2;
    CGSize size = [self returnRectWithString:contentStr andWidth:w];
    self.content.text = contentStr;
    self.content.frame = CGRectMake(kContentWidthSpace, kContentHeightSpace, w, size.height);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)dealloc
{
    self.content = nil;
    [super dealloc];
}

@end
